package com.wj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.wj.pojo.SeriesWorks;
import com.wj.dao.SeriesWorksMapper;
import com.wj.service.ISeriesWorksService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.utils.RespUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author wj
 * @since 2022-05-20
 */
@Service
public class SeriesWorksServiceImpl extends ServiceImpl<SeriesWorksMapper, SeriesWorks> implements ISeriesWorksService {
    @Autowired
    private SeriesWorksMapper seriesWorksMapper;

    @Override
    public RespUtil getSeries(String seriesName) {
        List<SeriesWorks> series = seriesWorksMapper.selectList(new QueryWrapper<SeriesWorks>().eq("series", seriesName));
        if (ObjectUtils.isNull(series)){
            return RespUtil.error("没有数据",null);
        }
        return RespUtil.success("",series);
    }

    @Override
    public RespUtil searchWorks(String searchText) {
        List<SeriesWorks> seriesWorks = seriesWorksMapper.searchWorks(searchText);
        if (!ObjectUtils.isEmpty(seriesWorks)){
            return RespUtil.success("成功",seriesWorks);
        }
        return RespUtil.error("失败");
    }
}
